package com.itmk.course_teacher.dao.impl;

import com.itmk.common.BaseDao;
import com.itmk.course_teacher.dao.CourseTeacherDao;
import com.itmk.course_teacher.entity.CourseTeacher;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

public class CourseTeacherDaoImpl extends BaseDao implements CourseTeacherDao {
    @Override
    public void add(CourseTeacher courseTeacher) {
        //1、定义sql
        String sql = "insert into course_teacher(teacher_id,course_id) values(?,?)";
        //2、定义handler
        BeanHandler<CourseTeacher> handler = new BeanHandler<>(CourseTeacher.class);
        //3、定义参数
        Object[] parms = {
                courseTeacher.getTeacherId(),
                courseTeacher.getCourseId()
        };
        try {
            query.insert(sql,handler,parms);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }
}
